package com.it.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.it.product.domain.ProductSpec;
import com.it.product.mapper.ProductSpecMapper;
import com.it.product.service.ICategoryService;
import com.it.product.service.IProductSpecService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: spzx-parent
 *
 * @author: 王宝贵
 * time: 2024/9/20 23:49 周五
 * description:
 */
@Service
public class ProductSpecServiceImpl extends ServiceImpl<ProductSpecMapper, ProductSpec> implements IProductSpecService {

    @Autowired
    ProductSpecMapper productSpecMapper;

    @Autowired
    ICategoryService categoryService;

    /**
     * 分页查询列表
     * @param productSpec 查询的条件
     * @return
     */
    @Override
    public List<ProductSpec> findPage(ProductSpec productSpec) {
        return productSpecMapper.findPage(productSpec);
    }


    /**
     * 根据商品规格id查询商品规则
     * @param id
     * @return
     */
    @Override
    public ProductSpec selectProductSpecById(Long id) {
        ProductSpec productSpec = productSpecMapper.selectById(id);
        List<Long> longs = categoryService.selectListById(productSpec.getCategoryId());
        productSpec.setCategoryIdList(longs);

        return productSpec;
    }


}
